package com.nxn.core.dao;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import com.nxn.core.utils.Page;

/**
 * <p>
 * Extend this interface if you want typesafe (no casting necessary) DAO's for
 * your domain objects.
 * 
 * @author Michael
 * @param <T>
 *            a type variable
 * @param <PK>
 *            the primary key for that type
 */
public interface GenericDao<T, PK extends Serializable> {

	public T get(Class<T> entityClass, PK id);
	
	public List<T> getAll(Class<T> entityClass);
	
	public boolean exists(Class<T> entityClass, PK id);
	
	public T save(T entity);
	
	public void remove(T entity);
	
	public List<T> findByProperty(Class<T> entityClass, String propertyName, Object value);
	
	public List<T> findByHql(String hql, Object... values);
	
	public List<T> findByNameParam(String queryString, Map<String, Object> queryParams);
	
	public List<T> findByNamedQuery(String queryName, Object... values);
	
	public List<T> findByNamedQueryAndNameParam(String queryName, Map<String, Object> queryParams);
	
	public Page<T> queryPage(final Page<T> page, final String hql, final Object... values);
	
	public Page<T> queryPage(final Page<T> page, final String hql, final Map<String, ?> values);
	
}